#!/bin/sh
# poracode-desktop-cli-v1
self=$0
hops=0
while [ -L "$self" ]; do
  [ "$hops" -lt 16 ] || { echo "Poracode command link loop." >&2; exit 1; }
  target=$(readlink "$self") || exit 1
  case "$target" in /*) self=$target ;; *) self=$(dirname "$self")/$target ;; esac
  hops=$((hops + 1))
done
dir=$(CDPATH= cd -P "$(dirname "$self")" && pwd) || exit 1
app="$dir/../../"'poracode-nightly-desktop'
if [ ! -x "$app" ]; then
  echo "Poracode desktop has moved or been removed. Open or reinstall the selected desktop release to repair its command." >&2
  exit 127
fi
exec env NODE_OPTIONS= NODE_PATH= ELECTRON_RUN_AS_NODE=1 "$app" "$dir/bootstrap.mjs" "$@"
